package com.cqgcxy.auth_module.service.impl;

import com.cqgcxy.auth_module.entity.User;
import com.cqgcxy.auth_module.mapper.UserMapper;
import com.cqgcxy.auth_module.service.AuthService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class AuthServiceImpl implements AuthService {

    private final UserMapper userMapper;

    public AuthServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public UserData login(String account, String password, String userType) {
        User user = userMapper.selectUserByAuth(account, password, userType);
        if (user == null) {
            throw new UserNotFoundException(account, password, userType);
        }
        return new UserData(
                user.getAccount(), user.getPassword(),
                user.getUsername(), user.getUserType()
        );
    }
}
